using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
using System.Collections;
using System.Runtime.InteropServices;
using System.ComponentModel;

namespace WindowsGame
{
    [Serializable, StructLayout(LayoutKind.Sequential), TypeConverter(typeof(System.Drawing.RectangleConverter))]
    public struct TileRect : IEquatable<TileRect>
    {
        public float X;
        public float Y;
        public float Width;
        public float Height;

        private static TileRect _empty;

        public float Bottom
        {
            get
            {
                return (this.Y + this.Height);
            }
        }

        public float Left
        {
            get
            {
                return this.X;
            }
        }

        public float Right
        {
            get
            {
                return (this.X + this.Width);
            }
        }

        public float Top
        {
            get
            {
                return this.Y;
            }
        }

        public static TileRect Empty
        {
            get
            {
                return _empty;
            }
        }

        public bool Intersects(TileRect value)
        {
            return ((((value.X < (this.X + this.Width)) && (this.X < (value.X + value.Width))) && (value.Y < (this.Y + this.Height))) && (this.Y < (value.Y + value.Height)));
        }

        public bool Equals(TileRect other)
        {
            return ((((this.X == other.X) && (this.Y == other.Y)) && (this.Width == other.Width)) && (this.Height == other.Height));
        }

        public override int GetHashCode()
        {
            return (((this.X.GetHashCode() + this.Y.GetHashCode()) + this.Width.GetHashCode()) + this.Height.GetHashCode());
        }

        public override bool Equals(object obj)
        {
            bool flag = false;
            if (obj is TileRect)
            {
                flag = this.Equals((TileRect)obj);
            }
            return flag;
        }

        public TileRect(float x, float y, float width, float height)
        {
            this.X = x;
            this.Y = y;
            this.Width = width;
            this.Height = height;
        }

        public static bool operator ==(TileRect a, TileRect b)
        {
            return ((((a.X == b.X) && (a.Y == b.Y)) && (a.Width == b.Width)) && (a.Height == b.Height));
        }

        public static bool operator !=(TileRect a, TileRect b)
        {
            if (((a.X == b.X) && (a.Y == b.Y)) && (a.Width == b.Width))
            {
                return (a.Height != b.Height);
            }

            return true;
        }

        static TileRect()
        {
            _empty = new TileRect();
        }
    }

    public abstract class MapObject
    {
        /// <summary>
        /// Draws an object to the map.
        /// </summary>
        /// <param name="batch">SpriteBatch object which draws.</param>
        public abstract void Draw(SpriteBatch batch);

        /// <summary>
        /// Draws an object to the map.
        /// </summary>
        /// <param name="batch">SpriteBatch object which draws.</param>
        /// <param name="alphaColor">Color for alpha blending.</param>
        public abstract void Draw(SpriteBatch batch, Color alphaColor);

        /// <summary>
        /// Gets and sets the object bounds.
        /// </summary>
        public abstract TileRect Bounds
        {
            get;
            set;
        }
    }
}
